home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / explode / explode.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-02-21  |  3.2 KB  |  69 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3165
  5.    ClientLeft      =   60
  6.    ClientTop       =   375
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3165
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Label Label1 
  13.       Caption         =   "This is a test!"
  14.       BeginProperty Font 
  15.          Name            =   "MS Sans Serif"
  16.          Size            =   18
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   2295
  24.       Left            =   480
  25.       TabIndex        =   0
  26.       Top             =   480
  27.       Width           =   3615
  28.    End
  29. Attribute VB_Name = "Form1"
  30. Attribute VB_GlobalNameSpace = False
  31. Attribute VB_Creatable = False
  32. Attribute VB_PredeclaredId = True
  33. Attribute VB_Exposed = False
  34. Option Explicit
  35. 'Mike McGrath (UK) 1998: This example opens form by increment steps to reach the forms set size
  36. Rem define type
  37. Private Type RECT
  38.         Left As Long
  39.         Top As Long
  40.         Right As Long
  41.         Bottom As Long
  42. End Type
  43. Rem declare api calls
  44. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  45. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
  46. Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  47. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  48. Private Sub Explode(Newform As Form, Increment As Integer)
  49. Dim Size As RECT                                                                                                ' setup form as rect type
  50. GetWindowRect Newform.hwnd, Size
  51. Dim FormWidth, FormHeight As Integer                                                                 ' establish dimension variables
  52. FormWidth = (Size.Right - Size.Left)
  53. FormHeight = (Size.Bottom - Size.Top)
  54. Dim TempDC
  55. TempDC = GetDC(ByVal 0&)                                                                                 ' obtain memory dc for resizing
  56. Dim Count, LeftPoint, TopPoint, nWidth, nHeight As Integer                                      ' establish resizing variables
  57. For Count = 1 To Increment                                                                               ' loop to new sizes
  58.     nWidth = FormWidth * (Count / Increment)
  59.     nHeight = FormHeight * (Count / Increment)
  60.     LeftPoint = Size.Left + (FormWidth - nWidth) / 2
  61.     TopPoint = Size.Top + (FormHeight - nHeight) / 2
  62.     Rectangle TempDC, LeftPoint, TopPoint, LeftPoint + nWidth, TopPoint + nHeight     ' draw rectangles to build form
  63. Next Count
  64. DeleteDC (TempDC)                                                                                           ' release  memory resource
  65. End Sub
  66. Private Sub Form_Load()
  67. Explode Me, 1000                                                                                             ' open this form by number of desired increment
  68. End Sub
  69.